import type { orderPayParams, OrderPreResult } from "@/types/create"
import { http } from "@/untils/request"

/**
 * 填写订单-获取预付订单
 * @returns 
 */
export const getOrderCreateListAPI = () => {
    return http<OrderPreResult>({
        url: '/member/order/pre',
        method: 'GET'
    })
}

/**
 * 填写订单-获取立即购买订单
 * @param data skuId,count,addressId
 * @returns 
 */
export const getOrderPaymentAPI = (data: {
    skuId: string,
    count: number,
    addressId?: string
}) => {
    return http<OrderPreResult>({
        url: '/member/order/pre/now',
        method: 'GET',
        data
    })
}

/**
 * 提交订单
 * @param data 
 * @returns 
 */
export const postMemberOrderAPI = (data: orderPayParams) => {
    return http<{ id: string }>({
        url: '/member/order',
        method: 'POST',
        data
    })
}